<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
      <title>GUI File Path Assignment | HiAPI-C# 2025 </title>
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta name="title" content="GUI File Path Assignment | HiAPI-C# 2025 ">
      
      
      <link rel="icon" href="../../../../img/HiAPI.favicon.ico">
      <link rel="stylesheet" href="../../../../public/docfx.min.css">
      <link rel="stylesheet" href="../../../../public/main.css">
      <meta name="docfx:navrel" content="../../../../toc.html">
      <meta name="docfx:tocrel" content="../../toc.html">
      
      <meta name="docfx:rel" content="../../../../">
      
      
      
      <meta name="loc:inThisArticle" content="In this article">
      <meta name="loc:searchResultsCount" content="{count} results for &quot;{query}&quot;">
      <meta name="loc:searchNoResults" content="No results for &quot;{query}&quot;">
      <meta name="loc:tocFilter" content="Filter by title">
      <meta name="loc:nextArticle" content="Next">
      <meta name="loc:prevArticle" content="Previous">
      <meta name="loc:themeLight" content="Light">
      <meta name="loc:themeDark" content="Dark">
      <meta name="loc:themeAuto" content="Auto">
      <meta name="loc:changeTheme" content="Change theme">
      <meta name="loc:copy" content="Copy">
      <meta name="loc:downloadPdf" content="Download PDF">

      <script type="module" src="./../../../../public/docfx.min.js"></script>

      <script>
        const theme = localStorage.getItem('theme') || 'auto'
        document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
      </script>

  </head>

  <body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
    <header class="bg-body border-bottom">
      <nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
        <div class="container-xxl flex-nowrap">
          <a class="navbar-brand" href="../../../../index.html">
            <img id="logo" class="svg" src="../../../../img/HiAPI.logo.png" alt="">
            
          </a>
          <button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
            <i class="bi bi-three-dots"></i>
          </button>
          <div class="collapse navbar-collapse" id="navpanel">
            <div id="navbar">
              <form class="search" role="search" id="search">
                <i class="bi bi-search"></i>
                <input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
              </form>
            </div>
          </div>
        </div>
      </nav>
    </header>

    <main class="container-xxl">
      <div class="toc-offcanvas">
        <div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
          <div class="offcanvas-header">
            <h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
            <button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
          </div>
          <div class="offcanvas-body">
            <nav class="toc" id="toc"></nav>
          </div>
        </div>
      </div>

      <div class="content">
        <div class="actionbar">
          <button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
            <i class="bi bi-list"></i>
          </button>

          <nav id="breadcrumb"></nav>
        </div>

        <article data-uid="">
          <h1 id="gui-file-path-assignment">GUI File Path Assignment</h1>

<p>See the remarks of <a class="xref" href="../../../../api/Hi.Common.XmlUtils.IMakeXmlSource.html#Hi_Common_XmlUtils_IMakeXmlSource_MakeXmlSource_System_String_System_String_System_Boolean_">MakeXmlSource(string, string, bool)</a> to know the design pattern of file path treatment.</p>
<p>if the assigned file path is descendent of the configuration directory, it is straight forward that set the <code>baseDirectory</code> to the configuration directory and apply relative path to <code>relFile</code>; if not, set <code>baseDirectory</code> to null and set <code>relFile</code> to absolute path.</p>
<p>GUI that needs to assign file generally requires a code-behind <code>BaseDirectory</code> property as assistent model. The property is assigned by the parent model from the parent GUI.</p>
<p>In most cases, the first <code>BaseDirectory</code> is the project directory if the project has assigned (created or loaded).</p>
<h2 id="portability">Portability</h2>
<p>To maintain For the portability of project or the other folder-based unit, if the sub-item is loaded by absolute path outside the folder-based unit directory, redirect the saving path to the folder-based unit directory, i.e. the SubItemFile below.</p>
<div class="NOTE">
<h5>Note</h5>
<p>You have no need to do an additional action to create a duplicate in the folder-based unit directory. Since the file-writing pattern of <a class="xref" href="../../../../api/Hi.Common.XmlUtils.IMakeXmlSource.html#Hi_Common_XmlUtils_IMakeXmlSource_MakeXmlSource_System_String_System_String_System_Boolean_">MakeXmlSource(string, string, bool)</a> create files when user call to save. In other perspective, if user does not call to save, the local duplicate should be created.</p>
</div>
<p>The design pattern is usually saw in the HiAPI program, a object contains the properties:</p>
<ul>
<li>object SubItem;</li>
<li>string SubItemFile;</li>
</ul>
<p>Then you should keep the Protability.</p>
<h2 id="file-path-of-load-button-and-save-button">File Path of Load Button and Save Button</h2>
<p>The genneral convention of the File Path of Load and Save is different by the single-user desktop application and web page application.</p>
<div class="TIP">
<h5>Tip</h5>
<p>Always preserve an empty filter ( * . * ) for the browser.</p>
</div>
<h3 id="single-user-desktop-application">Single-User Desktop Application</h3>
<p>The default directory of the Save/Load button are generally:</p>
<ul>
<li>System Default Directory or Project Directory (default, if not explicitly indicated)
The initial directory is the project directory.</li>
<li>Resource Directory
The path always point to <code>&lt;application path&gt;/Resource/&lt;classification&gt;</code> directory.
The button label has to explicitly show &lsquo;Load Resource&rsquo;.</li>
</ul>
<p>The kinds of buttons are not exclusive, they can be existed on the same tool bar.</p>
<p>If the selected file path is under the project directory, apply the relative path from the project, i.e. baseDirectory is project directory and relFile is the relative path.</p>
<h3 id="web-page-application">Web Page Application</h3>
<p>The default directory of the Save/Load button are generally:</p>
<ul>
<li>Admin Directory</li>
<li>Project Directory</li>
<li>Resource Directory</li>
</ul>
<p>The Resource Directory and Project Directory are generally under the Admin Directory. And the admin directory is generally set in the appsettings.json file.</p>
<h2 id="typical-action-if-exhibitiononly-false">Typical Action if <code>exhibitionOnly</code> false</h2>
<p>On <a class="xref" href="../../../../api/Hi.Common.XmlUtils.IMakeXmlSource.html">IMakeXmlSource</a>.<a class="xref" href="../../../../api/Hi.Common.XmlUtils.IMakeXmlSource.html#Hi_Common_XmlUtils_IMakeXmlSource_MakeXmlSource_System_String_System_String_System_Boolean_">MakeXmlSource(string, string, bool)</a> with <code>exhibitionOnly</code> false, the argument (<code>baseDirectory</code> and <code>relFile</code>) should be the same from object's host (if exist) XML output function.</p>

</article>

        <div class="contribution d-print-none">
        </div>

        <div class="next-article d-print-none border-top" id="nextArticle"></div>

      </div>

      <div class="affix">
        <nav id="affix"></nav>
      </div>
    </main>

    <div class="container-xxl search-results" id="search-results"></div>

    <footer class="border-top text-secondary">
      <div class="container-xxl">
        <div class="flex-fill">
          <span> Copyright © 2025 <a href='https://superhightech.com.tw'>Tech Coordinate</a>. All rights reserved. <a href='https://superhightech.com.tw'>超級高科技股份有限公司</a> © 2025 版權所有 </span>
        </div>
      </div>
    </footer>
  </body>
</html>
